#ifndef _APPLICATION_H_
#define _APPLICATION_H_

class Application
{
	public:
	   Application(int argc, char** argv);
        SDL_Surface* gameInit(int,int,int,string&,int);
	   SDL_Surface* getScreenSurface();
        bool gameEnd();
        bool stopped();
        void setFPS(int);
	   int getFPS();
	   void regulateFPS();
	private:
	   int fps;
	   int argc;
	   char** argv;
        bool done;
	   SDL_Surface* screen;
};

Application::Application(int _argc, char** _argv){
    this->argc = argc;
	this->argv = argv;
    done=false;
}

SDL_Surface* Application::gameInit(int W, int H, int BPP, std::string& caption, int _fps)
{
        if(SDL_Init(SDL_INIT_EVERYTHING)==-1){
            return NULL;
        }
        screen=SDL_SetVideoMode(W,H,BPP,SDL_SWSURFACE);
        Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096);
        TTF_Init();
        if(screen==NULL){
            return NULL;
        }
        SDL_WM_SetCaption(caption.c_str(), NULL);
        fps=_fps;
	return screen;
}

SDL_Surface* Application::getScreenSurface()
{
	return screen;
}

bool Application::gameEnd()
{
    done=true;
}

bool Application::stopped()
{
    return done;
}

void Application::setFPS(int _fps)
{
	fps=_fps;
}

int Application::getFPS()
{
	return fps;
}

void Application::regulateFPS()
{
	SDL_Delay((1000/getFPS()));
}

#endif
